package com.hcbd.tdwt.ui.setting.xingyu.activity;
import android.annotation.SuppressLint;
import android.widget.Button;
import android.widget.EditText;

import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.pangu.bdsdk2021.entity.extensionterminal.BDMDXInfo;
import com.pangu.bdsdk2021.terminal.TerminalSendManager;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_work_mode)
public class WorkModeActivity extends BaseActivity {
    @ViewById
    EditText rdssET,rnssET;
    @ViewById
    Button implementBtn;
    @AfterViews
    protected void init() {
        initMsgRegister();
        TerminalSendManager.getInstance().level_two_getMDQ();
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 1)
    public void eventBus(BDMDXInfo bdmdxInfo){
        rdssET.setText(bdmdxInfo.rdss);
        rnssET.setText(bdmdxInfo.rnss);
        toast("加载成功！");
    }
    @Click
    void implementBtn(){
        String rdss=getTextStr(rdssET);
        if("".equals(rdss)||(!"1".equals(rdss)&&!"0".equals(rdss))){
            toast("请输入正确RDSS使能值");
            return;
        }
        String rnss=getTextStr(rnssET);
        if("".equals(rnss)){
            toast("请输入RNSS使能值");
            return;
        }
        int rnssInt=Integer.parseInt(rnss);
        if(0>rnssInt||3<rnssInt){
            toast("请输入正确的RNSS使能值");
            return;
        }
        TerminalSendManager.getInstance().level_two_setMDS(Integer.parseInt(rdss),rnssInt);
        toast("已发送!");
    }
    @Click
    void headLeft(){
        finish();
    }
}
